package cn.itsource.pethome.basic.util;

import cn.itsource.pethome.user.domain.User;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

public class UserContext {

    public static User getLoginUser(HttpServletRequest request){
        //获取发布寻主的信息用户
        //通过U-TOKEN 查询token
        String token = request.getHeader("U-TOKEN");
        //在redis中返回用户信息json字符串
        String userJsonStr = RedisUtils.INSTANCE.get(token);
        //转换成user对象
        User user = JSONObject.parseObject(userJsonStr, User.class);
        //返回对象
        return user;
    }


}
